home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / Nuntius 1.2 / src / Nuntius / UArticleTextCache.h < prev    next >
Encoding:
Text File  |  1994-02-20  |  1.4 KB  |  59 lines  |  [TEXT/MPS ]

  1. // Copyright © 1992 Peter Speck, speck@dat.ruc.dk. All rights reserved.
  2. // UArticleTextCache.h
  3.  
  4. #define __UARTICLETEXTCACHE__
  5.  
  6. #ifndef __UPTROBJECT__
  7. #include "UPtrObject.h"
  8. #endif
  9.  
  10. const short kMaxNoCachedArticleTexts = 50;
  11.  
  12. class ArticleEntry
  13. {
  14.     public:
  15.         long fID;
  16.         Handle fH;
  17.         long fSize;
  18.         CStr255 fGroupDotName;
  19.         
  20.         ArticleEntry();
  21. };
  22. typedef ArticleEntry *ArticleEntryPtr;
  23.  
  24. class PArticleTextCache : public PPtrObject 
  25. {
  26.     public:
  27.     
  28.         Handle GetArticleText(const CStr255 &groupDotName, long id); // returns nil if article not avaible
  29.         // The handles are null terminated (PNntp does the job)
  30.         // OBS: PArticleTextCache _owns_ the handle!
  31.         // The handle is only valid until
  32.         //   1) GetArticle is called again
  33.         //   2) MacAppYield is called
  34.  
  35.         void FlushCache();
  36.         
  37.         void DebugDump();
  38.         
  39.         PArticleTextCache();
  40.         void IArticleTextCache();
  41.         ~PArticleTextCache();
  42.     private:        
  43.         ArticleEntry fArticleTable[kMaxNoCachedArticleTexts];
  44.  
  45.         short fOutIndex; // CPoints at entry that should be flushed when space is needed
  46.         short fInIndex; // CPoints on last fetched entry
  47.         short fLastUsedIndex; // CPoints on last used index
  48.         short fNoUsedEntries;
  49.         long fSumSize;
  50.         
  51.         void FlushOneArticle();
  52.         void FlushToFit(const long maxSumSize);
  53.         Handle GetArticleFromNntp(const CStr255 &groupDotName, long id);
  54. };
  55.  
  56. extern PArticleTextCache *gArticleTextCache;
  57. void InitUArticleTextCache();
  58. void CloseDownUArticleTextCache();
  59.